# -*- coding: utf-8 -*-
# todo.models

import simplejson

from google.appengine.ext import db

# Create your models here.
class Todo(db.Model):
    content = db.StringProperty(required=True)
    done = db.BooleanProperty()
    order = db.IntegerProperty()
    created = db.DateTimeProperty(auto_now_add=True)
    updated = db.DateTimeProperty(auto_now=True)

    def to_dict(self):
        data = {'id': self.key().id(),
            'content': self.content,
            'done': self.done,
            'order': self.order}
        return data

    def to_json(self):
        data_dict = self.to_dict()
        return simplejson.dumps(data_dict)
